package com.edwin.websitebe.controller;

import com.edwin.websitebe.util.OSSUtil;
import com.edwin.websitebe.vo.Ueditor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/editor")
@Slf4j
public class EditorController {

    @RequestMapping("/server")
    public Object server(String action, String callback, MultipartFile upfile) {
        if (Ueditor.ACTION_CONFIG.equals(action)) {
            return callback + "(" + Ueditor.UEDITOR_CONFIG + ")";
        } else {
            return OSSUtil.uploadEditorFile(upfile);
        }
    }

}
